package com.example.bootservice.service.impl;

import com.example.bootservice.dao.RepayPlanFileDao;
import com.example.bootservice.dto.RepayPlanFileDTO;
import com.example.bootservice.dto.UserDTO;
import com.example.bootservice.service.RepayPlanService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.math.BigDecimal;
import java.util.List;

@Service
public class RepayPlanServiceImpl implements RepayPlanService {
    @Autowired
    private RepayPlanFileDao repayPlanFileDao;

    @Override
    public void insert() {
        RepayPlanFileDTO repayPlanFileDTO = new RepayPlanFileDTO();
        repayPlanFileDTO.setProCode("sss");
        repayPlanFileDTO.setBizDate("20200110");
        repayPlanFileDTO.setContrNbr("2232131312312");
        repayPlanFileDTO.setProductCd("0051");
        repayPlanFileDTO.setRefNbr("ssasdsad12314");
        repayPlanFileDTO.setTerm(12);
        repayPlanFileDTO.setBeginDate("20210123");
        repayPlanFileDTO.setStmtDate("20210125");
        repayPlanFileDTO.setGraceDate("20210126");
        repayPlanFileDTO.setStatus("1");
        repayPlanFileDTO.setPrincipal(new BigDecimal(23333.00));
        repayPlanFileDTO.setPenaltyPaid(new BigDecimal(22323));
        repayPlanFileDTO.setPrincipalDue(new BigDecimal(213));
        repayPlanFileDTO.setPrincipalDue91(new BigDecimal(23));
        repayPlanFileDTO.setInterest(new BigDecimal(200));
        repayPlanFileDTO.setInterestPaid(new BigDecimal(100));
        repayPlanFileDTO.setInterestDue(new BigDecimal(20));
        repayPlanFileDTO.setInterestDue91(new BigDecimal(14));
        repayPlanFileDTO.setPenaltyPaid(new BigDecimal(2131));
        repayPlanFileDTO.setPenaltyDue(new BigDecimal(23));
        repayPlanFileDTO.setInitTerm(12);
        repayPlanFileDao.insertRepa(repayPlanFileDTO);
    }

    @Override
    public List<RepayPlanFileDTO> select() {
        return repayPlanFileDao.selectRepa();
    }

    @Override
    public void insertUser() {
        UserDTO userDTO = new UserDTO();
        userDTO.setUser("maon");
        userDTO.setPasswd("123");
        repayPlanFileDao.insertUser(userDTO);
    }
}
